-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: IBC transfer scenarios #10852
base: master
Are you sure you want to change the base?
test: IBC transfer scenarios #10852
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
21dbe29
to
014071b
Compare
014071b
to
33915c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm confusing myself on which hook does what. Do we have a flow diagram somewhere?
func (k Keeper) PacketStore(ctx sdk.Context, ourOrigin types.PacketOrigin, ourPort string, ourChannel string, sequence uint64) (storetypes.KVStore, []byte) { | ||
key := fmt.Sprintf("%s/%s/%s/%v", ourOrigin, ourPort, ourChannel, sequence) | ||
packetKey := []byte(key) | ||
return prefix.NewStore(ctx.KVStore(k.key), []byte(packetDataStoreKeyPrefix)), packetKey | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make a reference to https://github.com/agoric-labs/ibc-go/blob/v6.3.1-alpha.agoric.2/modules/core/24-host/keys.go#L183-L187 but mention we need to support both directions (hence the extra origin)?
Btw I like the paths used by IBC better because it denotes what each path element is in the name
originalData/{src|dst}/ports/{ourPort}/channel/{ourChannel}/sequences/{sequence}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
if StorePacketData && !bytes.Equal(strippedPacket.GetData(), packet.GetData()) { | ||
packetStore, packetKey := k.PacketStoreFromOrigin(ctx, types.PacketSrc, packet) | ||
if !packetStore.Has(packetKey) { | ||
packetStore.Set(packetKey, packet.GetData()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we remembering the packet data when receiving an ack? Shouldn't we assert we had saved packet data if we rewrote the packet, and delete instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, your suggestion is correct.
origPacket := packet | ||
packetStore, packetKey := k.PacketStoreFromOrigin(ctx, types.PacketSrc, packet) | ||
if packetStore.Has(packetKey) { | ||
origPacket.Data = packetStore.Get(packetKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused, why do we need to restore the original packet's data? Wouldn't a received timeout packet contain the original packet data in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. I've updated this to be the same logic as InterceptOnAckPacket above.
packet.GetDestPort(), packet.GetDestChannel(), | ||
timeout, packet.GetTimeoutTimestamp(), | ||
) | ||
packetStore, packetKey := k.PacketStoreFromOrigin(ctx, types.PacketSrc, packet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're writing an ack, wouldn't we be the destination / receiver? Why are we using a src origin here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, it should be PacketDst.
3a4bb6b
to
560a63a
Compare
There is some descriptive text in https://github.com/Agoric/agoric-sdk/pull/10852/files#diff-9f5147516ace799597d78cf5abf1f9d93de4304489b31628b02bc471143c4b84L13 that may help. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still reviewing, especially the tests, but I'm still not sure I understand the order of hooks invocation, especially in the case of ack received for sent ibc packets.
if StorePacketData && !bytes.Equal(strippedPacket.GetData(), packet.GetData()) { | ||
packetStore, packetKey := k.PacketStoreFromOrigin(ctx, types.PacketSrc, packet) | ||
if packetStore.Has(packetKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now this handles the case where stripped packet != packet && store.has(packet).
We have 3 other cases:
- store.has(packet) && stripped packet == packet. This arguably shouldn't happen, but I don't see a reason to not delete the stored data (if it matches the packet)?
- stripped packet != packet && !store.has(packet). Could this happen? Wouldn't IBC guarantee that we only see an ack only once for packet we actually sent? Even in the case of timeout. If true, is it worth asserting this is an unexpected packet or just trust IBC that this will never happen?
- stripped packet == packet && !store.has(packet). This is the normal case where the packet has not be modified and we have nothing to do.
@@ -180,6 +297,18 @@ func (k Keeper) InterceptOnTimeoutPacket( | |||
if err != nil { | |||
return err | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this is specific to timeout packets received from a relayer. Is there ever a case where the local IBC logic generates a timeout when it receives an update client past the timeout (after verifying the remote chain didn't include the sent packet in its state)
packetStore, packetKey := k.PacketStoreFromOrigin(ctx, types.PacketDst, packet) | ||
if packetStore.Has(packetKey) { | ||
origPacket.Data = packetStore.Get(packetKey) | ||
packetStore.Delete(packetKey) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this relate to the deletion done in func (i4 *ics4Wrapper) WriteAcknowledgement
?
Is there a case where we may have an async ack that no longer has the original data saved?
@@ -186,6 +186,6 @@ const queryAccountBalance = test.macro({ | |||
test.serial(queryAccountBalances, 'osmosis'); | |||
test.serial(queryAccountBalances, 'cosmoshub'); | |||
test.serial(queryAccountBalances, 'agoric'); | |||
test.serial(queryAccountBalance, 'osmosis'); | |||
test.serial.failing(queryAccountBalance, 'osmosis'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these failing now?
- min fees were set to 0 to allow the relayers to come up. likely not the best approach, but the most expedient for now
- allow callers to set broadcast mode and fees - allow callers to specify another binary, like osmosisd or gaiad
cfa9c95
to
41768bf
Compare
closes: #XXXX
refs: #XXXX
Description
Security Considerations
Scaling Considerations
Documentation Considerations
Testing Considerations
Upgrade Considerations